package dongze.com.ckdj.persistence.dao;

import org.greenrobot.greendao.annotation.Convert;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.ToOne;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.DaoException;
import org.greenrobot.greendao.annotation.Transient;
import org.greenrobot.greendao.converter.PropertyConverter;

/**
 * Created by fanqwz on 2017/7/31.
 */

@Entity
public class ServerUploadTask { // mass loss image upload task
    @Id
    Long id;
    Long imageId;
    @ToOne(joinProperty = "imageId")
    Image image;
    String type;
    Long recordId;
    Boolean force = false;
    @Convert(converter = StateConverter.class, columnType = Integer.class)
    State state = State.Undefined;
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }
    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 641415871)
    public void setImage(Image image) {
        synchronized (this) {
            this.image = image;
            imageId = image == null ? null : image.getId();
            image__resolvedKey = imageId;
        }
    }
    /** To-one relationship, resolved on first access. */
    @Generated(hash = 1513476086)
    public Image getImage() {
        Long __key = this.imageId;
        if (image__resolvedKey == null || !image__resolvedKey.equals(__key)) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            ImageDao targetDao = daoSession.getImageDao();
            Image imageNew = targetDao.load(__key);
            synchronized (this) {
                image = imageNew;
                image__resolvedKey = __key;
            }
        }
        return image;
    }
    @Generated(hash = 1517498479)
    private transient Long image__resolvedKey;
    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 992767342)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getServerUploadTaskDao() : null;
    }
    /** Used for active entity operations. */
    @Generated(hash = 1942910462)
    private transient ServerUploadTaskDao myDao;
    /** Used to resolve relations */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;
    public State getState() {
        return this.state;
    }
    public void setState(State state) {
        this.state = state;
    }
    public Boolean getForce() {
        return this.force;
    }
    public void setForce(Boolean force) {
        this.force = force;
    }
    public Long getRecordId() {
        return this.recordId;
    }
    public void setRecordId(Long recordId) {
        this.recordId = recordId;
    }
    public String getType() {
        return this.type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public Long getImageId() {
        return this.imageId;
    }
    public void setImageId(Long imageId) {
        this.imageId = imageId;
    }
    public Long getId() {
        return this.id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    @Generated(hash = 1864460649)
    public ServerUploadTask(Long id, Long imageId, String type, Long recordId,
            Boolean force, State state) {
        this.id = id;
        this.imageId = imageId;
        this.type = type;
        this.recordId = recordId;
        this.force = force;
        this.state = state;
    }
    @Generated(hash = 1995063682)
    public ServerUploadTask() {
    }

 }
